/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package wcos.apiconnect;

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;

/**
 *
 * @author htnghiep
 */
public class APIConnect {
    private String apiAddress;

    public APIConnect(String apiAddress) {
        this.apiAddress = apiAddress;
    }

    public void setApiAddress(String apiAddress) {
        this.apiAddress = apiAddress;
    }

    public InputStreamReader ApiJSonGet(String query) throws UnsupportedEncodingException, MalformedURLException, IOException {
        URL url = new URL(apiAddress + "?" + query);
        InputStreamReader reader = new InputStreamReader(url.openStream(), "UTF-8");        
        return reader;
    }
}
